﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Microsoft.Practices.Unity;
using WDA.Core;
using System.Threading;

namespace Sample
{
   [ServiceContract]
   public interface IFormatterService
   {
      [OperationContract]
      string FormatInt(int value);
      [OperationContract]
      string FormatDouble(double value);
   }
   [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
   public class FormatterService : IFormatterService
   {
      [Dependency(WDA.Core.WDAContainerNames.InternalContainerName)]
      public IUnityContainer Container { get; set; }		

		private static Logger _log = new Logger("Sample.ConverterService");

      #region IFormatterService Members
      public string FormatInt(int value)
      {
			IResponseTimeValue respTime = Container.Resolve<IResponseTimeValue>();
			_log.WriteInfo("Formatting {0}.", value);
			Thread.Sleep(respTime.Milliseconds);
         return value.ToString();
      }
      public string FormatDouble(double value)
      {
			IResponseTimeValue respTime = Container.Resolve<IResponseTimeValue>();
			_log.WriteInfo("Formatting {0}.", value);
			Thread.Sleep(respTime.Milliseconds);
         return value.ToString();
      }
      #endregion
   }
}
